package com.liang.excel.core;


import com.liang.excel.core.domain.BusinessData;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liangyehao
 * @version 1.0
 * @date 2021/4/24 11:01
 * @content
 */
public class DefaultExcelHandler extends AbstractExcelHandler<BusinessData> {

    @Override
    public List<BusinessData> weedOut(List<BusinessData> origin) {
        // 剔除录客情况-【商机前录入】、
        // 剔除【商机发起人是否为内部员工】-是、
        // 剔除【是否封禁用户】-是，
        // 剔除【业务类型】-估价，
        // 商机类型-选【IM】

        return origin.stream().filter(originData ->
                !"商机前录入".equals(originData.getRecordGuestIs()) &&
                        !"是".equals(originData.getWhetherBusinessSponsorsForInternalStaff()) &&
                        !"是".equals(originData.getWhetherToBanUsers()) &&
                        !"估价".equals(originData.getBusinessTypes()) &&
                        "IM".equalsIgnoreCase(originData.getBusinessType())
        ).collect(Collectors.toList());
    }

    @Override
    public List<BusinessData> sort(List<BusinessData> weedOuted) {
        return weedOuted.stream().sorted(Comparator.comparing(BusinessData::getStores)).collect(Collectors.toList());
//        return weedOuted;
    }

    @Override
    public List<BusinessData> deDuplication(List<BusinessData> sorted) {
        return sorted.stream().distinct().collect(Collectors.toList());
    }
}
